//
//  CustomTabBarController.m
//  YoucApp
//
//  Created by Liam on 12/9/12.
//
//

#import "CustomTabBarController.h"

@interface CustomTabBarController ()

@end

@implementation CustomTabBarController

@synthesize customTabBarView = _customTabBarView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated
{
	CGRect frame = self.tabBar.frame;
	
	frame.size.height = 40;
	frame.origin.y = self.view.bounds.size.height - frame.size.height;
	
	self.tabBar.frame = frame;

	for (UIView *view in self.view.subviews)
	{
        if (![view isKindOfClass:[UITabBar class]])
		{
            view.frame = CGRectMake(0, 0, frame.size.width, frame.origin.y);
            break;
        }
	}
	
    [super viewWillAppear:animated];
	
	self.customTabBarView.frame = self.tabBar.frame;
	[self.view addSubview:self.customTabBarView];
	self.tabBar.hidden = YES;
}

- (void)viewDidAppear:(BOOL)animated
{
	[super viewDidAppear:animated];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)click_tab:(id)sender {
	for (UIButton *button in self.customTabBarView.subviews)
	{
		if ([button isKindOfClass:[UIButton class]])
		{
			if (button == sender)
			{
				button.selected = YES;
				self.selectedIndex = button.tag;
			}
			else
			{
				button.selected = NO;
			}
		}
	}
}

- (void)dealloc {
	[_customTabBarView release];
	[super dealloc];
}
- (void)viewDidUnload {
	self.customTabBarView = nil;
	[super viewDidUnload];
}
@end
